package threat;

public class SyncDemo4 {
    public static void main(String[] args) {
        StringBuffer sb = new StringBuffer();

        Thread t1 = new Thread() {
            public void run() {
                for (int i = 0; i < 10000; i++) {
                    System.out.println("abc");
                }
            }
        };
        Thread t2 = new Thread() {
            public void run() {
                for (int i = 0; i < 10000; i++) {
                    System.out.println("def");
                }
            }
        };
        t1.start();
        t2.start();

        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println(sb.length());
        System.out.println(sb);
    }
}
